/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023.
 * Description: hkids tracepoint head file.
 * Author: weiyuchen
 * Create: 2023-09-15
 */

#ifndef HKIDS_TRACEPOINT_H
#define HKIDS_TRACEPOINT_H

#include <linux/tracepoint.h>

#ifdef CONFIG_HKIDS_CHK_MLTDOWN
DECLARE_TRACE(hkids_chkmdatt,
	      TP_PROTO(struct task_struct *task,
		       unsigned long addr, int code),
	      TP_ARGS(task, addr, code));
#else
static inline void trace_hkids_chkmdatt(struct task_struct *task,
			unsigned long addr, int code)
{
}
#endif

#ifdef CONFIG_HKIDS_CHK_HEAP_SPRAY
DECLARE_TRACE(hkids_chkhpspy,
	      TP_PROTO(unsigned int count),
	      TP_ARGS(count));
#else
static inline void trace_hkids_chkhpspy(unsigned int count)
{
}
#endif

#ifdef CONFIG_HKIDS_CHK_PRIV_ESCAPE
DECLARE_TRACE(hkids_chkprivesc,
	      TP_PROTO(const struct cred *old_cred, const struct cred *new_cred),
	      TP_ARGS(old_cred, new_cred));
#else
static inline void trace_hkids_chkprivesc(const struct cred *old_cred,
			const struct cred *new_cred)
{
}
#endif

#ifdef CONFIG_HKIDS_CHK_ABNORMAL_EXIT
DECLARE_TRACE(hkids_chkabexit,
	      TP_PROTO(int sig, struct task_struct *sender,
		       struct task_struct *receiver),
	      TP_ARGS(sig, sender, receiver));
#else
static inline void trace_hkids_chkabexit(int sig, struct task_struct *sender,
			struct task_struct *receiver)
{
}
#endif

#ifdef CONFIG_HKIDS_CHK_INJECTION
DECLARE_TRACE(hkids_chkabptratt,
	      TP_PROTO(struct task_struct *tracer, struct task_struct *tracee),
	      TP_ARGS(tracer, tracee));
DECLARE_TRACE(hkids_chkabmemfd,
	      TP_PROTO(struct task_struct *task),
	      TP_ARGS(task));
#else
static inline void trace_hkids_chkabptratt(struct task_struct *tracer,
			struct task_struct *tracee)
{
}
static inline void trace_hkids_chkabmemfd(struct task_struct *task)
{
}
#endif

#endif
